Method, apparatus, and device for labeling images

ABSTRACT

A method, apparatus, and device for labeling images of PCBs includes obtaining an image to be tested; comparing the image to be tested to a reference image to generate an image mask, the image mask includes several connected domains; detecting defects of the image to be tested; when at least one defect detected in the image to be tested, obtaining a coordinate of the at least one defect; based on a central coordinate of the connected domains and the coordinate of the at least one defect, determining the connected domains to be defect connected domains or normal connected domains; generating a first image mask and a second image mask; and processing the first image mask and the second image mask with the image to be tested to obtain a defect element image corresponding to the defect connected domains and a normal element image corresponding to the normal connected domains.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims priority to Chinese Patent Application No.202110183358.2 filed on Feb. 9, 2021, the contents of which areincorporated by reference herein.

FIELD

The subject matter herein generally relates to data labeling technology,and particularly to a method, an apparatus, and a device for labelingimages.

BACKGROUND

Surface mounted technology (SMT) is precise and complicated in relationto printed circuit boards (PCB), and different defects in the PCB canoccur during the manufacture. Images of PCBs showing defects and imagesof normal (defect-free) PCBs need to be gathered, as negative andpositive samples respectively, during a neural network training process.Thus, for PCBs in different categories, if labeling the image of the PCBis done manually, a great deal of manpower and time may be spent.

BRIEF DESCRIPTION OF THE DRAWINGS

Many aspects of the disclosure can be better understood with referenceto the following drawings. The components in the drawings are notnecessarily drawn to scale, the emphasis instead being placed uponclearly illustrating the principles of the disclosure. Moreover, in thedrawings, like reference numerals designate corresponding partsthroughout the several views.

FIG. 1 illustrates a flowchart of at least one embodiment of a methodfor labeling images.

FIG. 2 illustrates a subsidiary flowchart of at least one embodiment ofa block S2 of the method of FIG. 1.

FIG. 3 illustrates a subsidiary flowchart of at least one embodiment ofa block S5 of the method of FIG. 1.

FIG. 4 illustrates a subsidiary flowchart of at least one embodiment ofa block S6 of the method of FIG. 1.

FIG. 5 illustrates a subsidiary flowchart of at least one embodiment ofa block S7 of the method of FIG. 1.

FIG. 6 shows application scenarios of at least one embodiment of themethod of FIG. 1.

FIG. 7 illustrates a block view of at least one embodiment of a devicefor labeling images.

FIG. 8 illustrates a block view of at least one embodiment of anapparatus for performing the method for labeling images.

DETAILED DESCRIPTION

It will be appreciated that for simplicity and clarity of illustration,where appropriate, reference numerals have been repeated among thedifferent figures to indicate corresponding or analogous elements. Inaddition, numerous specific details are set forth in order to provide athorough understanding of the embodiments described herein. However, itwill be understood by those of ordinary skill in the art that theembodiments described herein can be practiced without these specificdetails. In other instances, methods, procedures, and components havenot been described in detail so as not to obscure the related relevantfeature being described. Also, the description is not to be consideredas limiting the scope of the embodiments described herein. The drawingsare not necessarily to scale and the proportions of certain parts havebeen exaggerated to better illustrate details and features of thepresent disclosure.

The present disclosure, including the accompanying drawings, isillustrated by way of examples and not by way of limitation. Severaldefinitions that apply throughout this disclosure will now be presented.It should be noted that references to “an” or “one” embodiment in thisdisclosure are not necessarily to the same embodiment, and suchreferences mean “at least one.”

Furthermore, the term “module”, as used herein, refers to logic embodiedin hardware or firmware, or to a collection of software instructions,written in a programming language, such as Java, C, or assembly. One ormore software instructions in the modules can be embedded in firmware,such as in an EPROM. The modules described herein can be implemented aseither software and/or hardware modules and can be stored in any type ofnon-transitory computer-readable medium or another storage device. Somenon-limiting examples of non-transitory computer-readable media includeCDs, DVDs, BLU-RAY, flash memory, and hard disk drives. The term“comprising” means “including, but not necessarily limited to”; it indetail indicates open-ended inclusion or membership in a so-describedcombination, group, series, and the like.

FIG. 1 illustrate at least one embodiment of a method for identifyingand labeling images of printed circuit boards (PCBs) manufactured forSMT purposes, and which reveal defects in the PCB (negative sample) orno defects (positive sample).

The method is provided by way of example, as there are a variety of waysto carry out the method. Each block shown in FIG. 1 represents one ormore processes, methods, or subroutines carried out in the examplemethod. Furthermore, the illustrated order of blocks is by example onlyand the order of the blocks can be changed. Additional blocks may beadded or fewer blocks may be utilized, without departing from thisdisclosure. The example method can begin at block S1.

At block S1, obtaining an image to be tested.

At block S2, comparing the image to be tested to a reference image togenerate an image mask, the image mask includes several connecteddomains.

As shown in FIG. 2, in at least one embodiment, the block S2 furtherincludes:

At block S21, operating a grayscale processing to the image to be testedand the reference image, respectively, to obtain a first image and asecond image.

At block S22, comparing the first image and the second image to obtain athird image.

At block S23, operating a binarization processing to the third image toobtain a fourth image,

At block S24, processing a connected domain labeling to the fourth imageto obtain the image mask, the image mask includes the several connecteddomains.

In at least one embodiment, in block S21, the grayscale processing meansconverting the reference image and the image to be tested to grayscaleimages with one pixel value in each pixel.

In at least one embodiment, in block S22, calculating a mean-squareerror (MSE) of the first image and the second image or calculating astructural similarity (SSIM) index of the first image and the secondimage, to obtain the third image.

In at least one embodiment, block S23 may further include:

obtaining a threshold value;

setting grayscale values of the pixels in the third image that aregreater than or equal to the threshold value as a first pixel value, andsetting grayscale values of the pixels in the third image that aresmaller than the threshold value as a second pixel value, so as toobtain the fourth image.

The threshold value is not limited by the present disclosure, forinstance, the threshold value in block S23 may be a global thresholdvalue or a self-adapting threshold value. Different threshold values maybe selected according to different binarization algorithms by a personhaving ordinary skill in the art.

In at least one embodiment, the connected domain in block S24 means animage area formed by neighboring pixels with a same pixel value in thefourth image. The connected domains labeling means labeling everyconnected domain in the fourth image and recording all coordinate valuescorresponding to every labeling value.

In at least one embodiment, pixel values of the pixels in the severalconnected domains of the image mask may be the first pixel value. Thepixel values of the pixels beyond the several connected domains of theimage mask may be the second pixel value.

In at least one embodiment, in block S23, the first pixel value may be1, the second pixel value may be 0.

In at least one embodiment, in block S24, there may be several connecteddomains labeling algorithms, which is not limited by the presentdisclosure. For instance, the connected domains labeling algorithm maybe a connected domains labeling algorithm based on route or based onprofile. In at least one embodiment, the connected domains labelingalgorithm may be as used in prior art, further details are not given.

In at least one embodiment, the image to be tested includes an imagehaving a printed circuit board assembly (PCBA) with electroniccomponents. The reference image includes an image having a printedcircuit board (PCB) without any electronic components.

In at least one embodiment, each of the connected domains of the imagemask corresponds to the electronic components.

In at least one embodiment, before block S21, pre-processing thereference image and the image to be tested.

In at least one embodiment, the pre-processing includes:

Translating, rotating, or zooming the reference image and the image tobe tested, to unify the directions of the reference image and severalimages to be tested;

Adjusting the reference image and the image to be tested to standardsizes.

In at least one embodiment, the reference image, the image to be tested,the first image, the second image, the third image, the fourth image,and the image mask all have a same size.

At block S3, detecting defects of the image (detecting defects) to betested.

In at least one embodiment, detecting defects of the image to be testedby a trained neural network model.

In at least one embodiment, detecting defects of the image to be testedmay be by other ways, such as an image erosion and/or image dilatingalgorithm, which is not limited by the present disclosure.

At block S4, when at least one defect is revealed in the image to betested, obtaining a coordinate of the at least one defect.

At block S5, based on a central coordinate of the connected domains andthe coordinate of the at least one defect, determining the connecteddomains to be defect connected domains or normal connected domains.

As shown in FIG. 3, block S5 further includes:

At block S51, calculating a central coordinate of the several connecteddomains, to obtain several central coordinates;

At block S52, calculating a Euclidean distance of each defect coordinateand the several central coordinates, to obtain several Euclideandistances;

At block S53, selecting the defect connected domains according to apredetermined rule, and labeling other connected domains of the imagemask as normal connected domains.

In at least one embodiment, the central coordinate may be a centroidcoordinate.

Thus, at block S51, several centroid coordinates may be calculated bythe following centroid coordinate calculation (formula (1)):

$\begin{matrix}{{X = \frac{\sum_{{({i,j})} \in S}i}{N}}{Y = \frac{\sum_{{({i,j})} \in S}j}{N}}} & (1)\end{matrix}$

In formula (1), X and Y mean an abscissa coordinate and a verticalcoordinate of the centroid coordinate, S means connected domain, (i,j)means a coordinate of each pixel of the connected domain, and N means aquantity of the pixel of the connected domain.

In at least one embodiment, the Euclidean distance means a real distancebetween two points in a multi-dimensional space. In at least oneembodiment, since the image mask and the image to be tested are samesize, the defect coordinate of the image to be tested and the image maskwill be in a same position. Thus, at block S52, the Euclidean distancebetween the defect coordinate and the central coordinate means adistance between the defect coordinate and the central coordinate in theimage mask. Therefore, Euclidean distances between the defect coordinateand the central coordinate of each connected domain may be calculated bythe following Euclidean distance calculation (formula (2)):

ρ=√{square root over ((i ₂ −i ₁)²−(j ₂ −j ₁)²)}  (2)

In formula (2), (i₁, j₁) means a central coordinate of anyone of theconnected domain, (i₂, j₂) means a defect coordinate, and ρ means aEuclidean distance between the defect coordinate and the centralcoordinate.

At block S53, the predetermined rule may be: selecting a minimum valuefrom each of the several Euclidean distances, to obtain several minimumvalues; selecting several connected domains corresponding to the severalEuclidean distances, and labeling as the defect connected domains.

At block S6, generating a first image mask and a second image maskcorresponding to the defect connected domains and the normal connecteddomains. As shown in FIG. 4, block S6 further includes:

At block S61, setting the pixel values of the pixels of the normalconnected domains in the image mask as 0, to obtain the first imagemask.

At block S62, repeating block S61, to set the pixel values of the pixelsof the defect connected domains in the image mask as 0, thereforeobtaining the second image mask.

At block S7, processing the first image mask and the second image maskwith the image to be tested, respectively, to obtain a defect elementimage corresponding to the defect connected domains and a normal elementimage corresponding to the normal connected domains. As shown in FIG. 5,block S7 may further include:

At block S71, multiplying the first image mask and the image to betested, to obtain the defect element image and labeling the defectcoordinate in the defect element image;

At block S72, multiplying the second image mask and the image to betested, to obtain the normal element image.

In other embodiments, when the result of detection at block S3 is thatno defects are revealed in the image to be tested, that is, that theimage mask is the second image mask, block S7 is processed, to obtainnormal element images.

As shown in FIG. 6, in at least one embodiment, the image to be testedincludes two electronic elements.

First of all, obtaining a reference image corresponding to an image tobe tested, the image to be tested includes two electronic elements.Comparing the image to be tested and the reference image, to generate animage mask corresponding to the image to be tested. The image maskincludes a connected domain 1 and a connected domain 2.

Then, detecting defects in the image to be tested, and a result ofdetection is that a defect (a triangle area in the figure) exists in theimage to be tested, and then obtaining a defect coordinate correspondingto the defect.

Then, calculating centroid coordinates of the connected domain 1 and theconnected domain 2 according to the centroid coordinate calculationformula, respectively, and recording as central coordinate a and acentral coordinate b accordingly. Then calculating Euclidean distancesbetween each of the central coordinate a and the central coordinate band the defect coordinate, respectively, recording as a Euclideandistance (1) and a Euclidean distance (2). Comparing the Euclideandistance (1) and the Euclidean distance (2), to determine whetherEuclidean distance (1) is greater than the Euclidean distance (2), thatis, that the connected domain 1 is regarded as a normal connecteddomain, and the connected domain 2 is regarded as a defect connecteddomain corresponding to the defect.

Then setting the pixel values of the pixels of the normal connecteddomain in the image mask as 0, to obtain a first image mask; repeatingthis procedure to set the pixel values of the pixels of the defectconnected domain in the image mask as 0, to obtain a second image mask.

Then multiplying the first image mask and the image to be tested, toobtain a defect element image and labeling the defect in the defectelement image; multiplying the second image mask and the image to betested, to obtain a normal element image.

By comparing the reference image and image to be tested, obtaining animage mask including several connected domains. When defects arerevealed in the image to be tested, obtaining defect connected domainscorresponding to the defects, and labeling the connected domains of theimage mask besides the defect connected domains as normal connecteddomains. Setting pixel values of the pixels of the normal connecteddomains of the image mask to be 0, to obtain a first image mask; andsetting pixel values of the pixels of the defect connected domains ofthe image mask to be 0, to obtain a second image mask. Multiplying thefirst image mask and the image to be tested, to obtain a defect elementimage; and multiplying the second image mask and the image to be tested,to obtain a normal element image. When no defect are revealed in theimage to be tested, multiplying the image mask and the image to betested, to obtain the normal element image. The method for labelingimages decreases amount of human labor for labeling data.

FIG. 7 illustrates at least one embodiment of a device 100 for labelingimages. The device 100 for labeling images includes an obtaining module101, a comparing module 102, a defect detecting module 103, a coordinateobtaining module 104, a determining module 105, a mask generating module106, and a processing module 107.

The obtaining module 101 is configured to obtain an image to be tested.

The comparing module 102 is configured to compare the image to be testedto a reference image to generate an image mask, the image mask includesseveral connected domains.

The defect detecting module 103 is configured to detect defects revealedin the image to be tested.

The coordinate obtaining module 104 is configured to obtain a coordinateof at least one defect when a detection by the defect detecting module103 reveals at least one defect in the image to be tested.

The determining module 105 is configured to, based on a centralcoordinate of the connected domain and the coordinate of the at leastone defect, determine the connected domain to be a defect connecteddomain or a normal connected domain.

The mask generating module 106 is configured to generate a first imagemask and a second image mask respectively corresponding to the defectconnected domains and the normal connected domains.

The processing module 107 is configured to process the first image maskand the second image mask with the image to be tested to respectivelyobtain a defect element image corresponding to the defect connecteddomain and a normal element image corresponding to the normal connecteddomain.

In at least one embodiment, when the detection by the defect detectingmodule 103 is that no defect is revealed in the image to be tested, thatis that the image mask is the second image mask, the processing module107 is configured to process the second image mask with the image to betested, to obtain a normal element image.

In at least one embodiment, the obtaining module 101, the comparingmodule 102, the defect detecting module 103, the coordinate obtainingmodule 104, the determining module 105, the mask generating module 106,and the processing module 107 are configured to perform blocks S1 to S7of the method for labeling images, see above description for blocks S1to S7.

FIG. 8 illustrates an apparatus 200 including a memory 201, at least oneprocessor 202, and a computer program 203. The computer program 203 canbe stored in the memory 201 and processed by the processor 202.

The apparatus 200 may be a smart phone, a tablet computer, a laptopcomputer, an embedded computer, a personal computer, or a server. In atleast one embodiment, the apparatus 200 may include more or lesscomponents, modules, circuits, elements, or assemblies other than themodules shown in the figures.

In at least one embodiment, the memory 201 can include various types ofnon-transitory computer-readable storage mediums. For example, thememory 201 can be an internal storage system, such as a flash memory, arandom access memory (RAM) for the temporary storage of information,and/or a read-only memory (ROM) for permanent storage of information.The memory 201 can also be an external storage system, such as a harddisk, a storage card, or a data storage medium.

In at least one embodiment, the processor 202 can be a centralprocessing unit (CPU), a microprocessor, a digital signal processor(DSP), an application specific integrated circuit (ASIC), afield-programmable gate array (FPGA), a data processor chip, aprogrammable logic device (PLD), a discrete gate/transistor logicdevice, or a discrete hardware component. The processor 202 may beelectrically connected to other elements of the apparatus 200 throughinterfaces or a bus. In at least one embodiment, the apparatus 200includes a plurality of interfaces configured to communicate with otherdevices or apparatus.

In at least one embodiment, the computer program 203 is configured to beprocessed by the processor 202 to perform the method for labelingimages, such as blocks S1 to S7 of the method for labeling images. Thecomputer program 203 may also be processed by the processor 202 toperform the functions of the modules of the device 100 for labelingimages, such as the obtaining module 101, the comparing module 102, thedefect detecting module 103, the coordinate obtaining module 104, thedetermining module 105, the mask generating module 106, and theprocessing module 107.

In at least one embodiment, the computer program 203 can be divided intoone or more elements/modules, such as the obtaining module 101, thecomparing module 102, the defect detecting module 103, the coordinateobtaining module 104, the determining module 105, the mask generatingmodule 106, and the processing module 107 shown in FIG. 7, the one ormore elements/modules are stored in the memory 201 and can be run by theat least one processor 202 to perform the method for labeling images.The one or more elements/modules can be computer program instructionsdescribing process of the apparatus 200 for labeling images.

In at least one embodiment, the computer program 203 can benon-transitory computer program medium integrated in the processor 202and processed by the least one processor 202 to perform the method forlabeling images shown in FIGS. 1-5.

In at least one embodiment, the computer program 203 can be an automatedoptical inspection (AOI) apparatus configured to detect defects ofwelding.

It is believed that the present embodiments and their advantages will beunderstood from the foregoing description, and it will be apparent thatvarious changes may be made thereto without departing from the spiritand scope of the disclosure or sacrificing all of its materialadvantages, the examples hereinbefore described merely being embodimentsof the present disclosure.

What is claimed is:
 1. A method for labeling images comprising:obtaining an image to be tested; comparing the image to be tested to areference image to generate an image mask, the image mask includesseveral connected domains; detecting defects of the image to be tested;when at least one defect detected in the image to be tested, obtaining acoordinate of the at least one defect; based on a central coordinate ofthe connected domains and the coordinate of the at least one defect,determining the connected domains to be defect connected domains ornormal connected domains; generating a first image mask and a secondimage mask corresponding to the defect connected domains and the normalconnected domains; and processing the first image mask and the secondimage mask with the image to be tested, respectively, to obtain a defectelement image corresponding to the defect connected domains and a normalelement image corresponding to the normal connected domains.
 2. Themethod according to claim 1, wherein the comparing the image to betested to a reference image to generate an image mask, the image maskincludes several connected domains further comprises: operating agrayscale processing to the image to be tested and the reference image,respectively, to obtain a first image and a second image; comparing thefirst image and the second image to obtain a third image; operating abinarization processing to the third image to obtain a fourth image; andprocessing a connected domain labeling to the fourth image to obtain theimage mask, the image mask includes the several connected domains. 3.The method according to claim 2, wherein calculating a mean-square error(MSE) of the first image and the second image or calculating astructural similarity (SSIM) index of the first image and the secondimage, to obtain the third image.
 4. The method according to claim 1,wherein the based on a central coordinate of the connected domains andthe coordinate of the at least one defect, determining the connecteddomains to be defect connected domains or normal connected domainsfurther comprises: calculating a central coordinate of the severalconnected domains, to obtain several central coordinates; calculating aEuclidean distance of the coordinate of the at least one defect and theseveral central coordinates, to obtain several Euclidean distances; andselecting the defect connected domains according to a predeterminedrule, and labeling other connected domains of the image mask as normalconnected domains.
 5. The method according to claim 4, wherein thecentral coordinate is a centroid coordinate of the connected domains. 6.The method according to claim 4, wherein the predetermined rule isselecting a minimum value from each of the sever wherein the centralcoordinate is a centroid coordinate of the connected domains.alEuclidean distances, to obtain several minimum values; selecting severalconnected domains corresponding to the several Euclidean distances,labeling as the defect connected domains.
 7. The method according toclaim 1, wherein the generating a first image mask and a second imagemask corresponding to the defect connected domains and the normalconnected domains further comprises: setting pixel values of pixels ofthe normal connected domains in the image mask as 0, to obtain the firstimage mask; and repeating the former procedure, to set pixel values ofpixels of the defect connected domains in the image mask as 0, thereforeobtaining the second image mask.
 8. The method according to claim 1,wherein the processing the first image mask and the second image maskwith the image to be tested, respectively, to obtain a defect elementimage corresponding to the defect connected domains and a normal elementimage corresponding to the normal connected domains further comprises:multiplying the first image mask and the image to be tested, to obtainthe defect element image and labeling the coordinate of the at least onedefect in the defect element image; and multiplying the second imagemask and the image to be tested, to obtain the normal element image. 9.The method according to claim 1, wherein when no defect is detected inthe image to be tested, that is the image mask is the second image mask,multiplying the image mask and the image to be tested, to obtain thenormal element image.
 10. An apparatus for labeling images comprising:at least one processor; and at least one memory coupled to the at leastone processor and storing program instructions; the memory and theprogram instructions configured to, with the at least one processor,cause the apparatus to perform: obtaining an image to be tested;comparing the image to be tested to a reference image to generate animage mask, the image mask includes several connected domains; detectingdefects of the image to be tested; when at least one defect detected inthe image to be tested, obtaining a coordinate of the at least onedefect; based on a central coordinate of the connected domains and thecoordinate of the at least one defect, determining the connected domainsto be defect connected domains or normal connected domains; generating afirst image mask and a second image mask corresponding to the defectconnected domains and the normal connected domains; and processing thefirst image mask and the second image mask with the image to be tested,respectively, to obtain a defect element image corresponding to thedefect connected domains and a normal element image corresponding to thenormal connected domains.
 11. The apparatus according to claim 10,wherein the comparing the image to be tested to a reference image togenerate an image mask, the image mask includes several connecteddomains further comprises: operating a grayscale processing to the imageto be tested and the reference image, respectively, to obtain a firstimage and a second image; comparing the first image and the second imageto obtain a third image; operating a binarization processing to thethird image to obtain a fourth image; and processing a connected domainlabeling to the fourth image to obtain the image mask, the image maskincludes the several connected domains.
 12. The apparatus according toclaim 11, wherein calculating a mean-square error (MSE) of the firstimage and the second image or calculating a structural similarity (SSIM)index of the first image and the second image, to obtain the thirdimage.
 13. The apparatus according to claim 10, wherein the based on acentral coordinate of the connected domains and the coordinate of the atleast one defect, determining the connected domains to be defectconnected domains or normal connected domains further comprises:calculating a central coordinate of the several connected domains, toobtain several central coordinates; calculating a Euclidean distance ofthe coordinate of the at least one defect and the several centralcoordinates, to obtain several Euclidean distances; and selecting thedefect connected domains according to a predetermined rule, and labelingother connected domains of the image mask as normal connected domains.14. The apparatus according to claim 13, wherein the central coordinateis a centroid coordinate of the connected domains.
 15. The apparatusaccording to claim 13, wherein the predetermined rule is selecting aminimum value from each of the sever wherein the central coordinate is acentroid coordinate of the connected domains.al Euclidean distances, toobtain several minimum values; selecting several connected domainscorresponding to the several Euclidean distances, labeling as the defectconnected domains.
 16. The apparatus according to claim 10, wherein thegenerating a first image mask and a second image mask corresponding tothe defect connected domains and the normal connected domains furthercomprises: setting pixel values of pixels of the normal connecteddomains in the image mask as 0, to obtain the first image mask; andrepeating the former procedure, to set pixel values of pixels of thedefect connected domains in the image mask as 0, therefore obtaining thesecond image mask.
 17. The apparatus according to claim 10, wherein theprocessing the first image mask and the second image mask with the imageto be tested, respectively, to obtain a defect element imagecorresponding to the defect connected domains and a normal element imagecorresponding to the normal connected domains further comprises:multiplying the first image mask and the image to be tested, to obtainthe defect element image and labeling the coordinate of the at least onedefect in the defect element image; and multiplying the second imagemask and the image to be tested, to obtain the normal element image. 18.The apparatus according to claim 10, wherein when no defect is detectedin the image to be tested, that is the image mask is the second imagemask, multiplying the image mask and the image to be tested, to obtainthe normal element image.
 19. A device for labeling images comprising:an obtaining module configured to obtain an image to be tested; acomparing module configure to compare the image to be tested to areference image to generate an image mask, the image mask includesseveral connected domains; a defect detecting module configured todetect defects of the image to be tested; a coordinate obtaining moduleconfigured to, when at least one defect detected in the image to betested, obtain a coordinate of the at least one defect; a determiningmodule configured to, based on a central coordinate of the connecteddomains and the coordinate of the at least one defect, determine theconnected domains to b e defect connected domains or normal connecteddomains; a mask generating module configured to generate a first imagemask and a second image mask corresponding to the defect connecteddomains and the normal connected domains; and a processing moduleconfigured to process the first image mask and the second image maskwith the image to be tested, respectively, to obtain a defect elementimage corresponding to the defect connected domains and a normal elementimage corresponding to the normal connected domains.